package com.example.demo.T2.util;

import java.util.Random;

/**
 * RangeRandomUtils..
 *
 * @author Lizhong
 * @date 2020/8/21
 */
public class RangeRandomUtils {
    static Random random = new Random();

    public static int rangeRandom(int n, int m) {
        Random random = new Random();
        int i = random.nextInt(m) % (m - n + 1) + n;
        return i;
    }


    /**
     * 精确1000位
     * @param n
     * @param m
     * @return
     */
    public static double rangeRandomX(int n, int m) {
        double i = random.nextInt(m * 1000) % (m * 1000 - n * 1000 + 1) + n * 1000;
        return i / 1000;
    }
}
